home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-installer.exe / bin / quodlibet / ext / covers / musicbrainz.pyc (.txt) < prev   
Python Compiled Bytecode  |  2014-12-31  |  2KB  |  53 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. from os import path
  5. from gi.repository import Soup
  6. from quodlibet.plugins.cover import CoverSourcePlugin, cover_dir
  7. from quodlibet.util.cover.http import HTTPDownloadMixin
  8. from quodlibet.util.path import escape_filename
  9.  
  10. class MusicBrainzCover(CoverSourcePlugin, HTTPDownloadMixin):
  11.     PLUGIN_ID = 'musicbrainz-cover'
  12.     PLUGIN_NAME = _('MusicBrainz cover source')
  13.     PLUGIN_DESC = _("Download covers from musicbrainz's cover art archive")
  14.     PLUGIN_VERSION = '1.0'
  15.     
  16.     def group_by(cls, song):
  17.         return song.get('musicbrainz_albumid', None)
  18.  
  19.     group_by = classmethod(group_by)
  20.     
  21.     def priority():
  22.         return 0.65
  23.  
  24.     priority = staticmethod(priority)
  25.     
  26.     def cover_path(self):
  27.         mbid = self.mbid
  28.         if mbid is None:
  29.             return super(MusicBrainzCover, self).cover_path
  30.         return None.join(cover_dir, escape_filename(mbid))
  31.  
  32.     cover_path = property(cover_path)
  33.     
  34.     def mbid(self):
  35.         return self.song.get('musicbrainz_albumid', None)
  36.  
  37.     mbid = property(mbid)
  38.     
  39.     def url(self, front = True):
  40.         if not self.mbid:
  41.             return None
  42.         mbid = None.URI.encode(self.mbid, None)
  43.         return 'http://coverartarchive.org/release/{0}/front'.format(mbid)
  44.  
  45.     url = property(url)
  46.     
  47.     def fetch_cover(self):
  48.         if not self.mbid:
  49.             return self.fail('MBID is required to fetch the cover')
  50.         None.download(Soup.Message.new('GET', self.url))
  51.  
  52.  
  53.